<?php

namespace App\Http\Controllers\v1\activity;

use App\Http\Controllers\Controller;
use App\services\v1\LuckServices;
use Dingo\Api\Http\Request;
use Illuminate\Validation\ValidationException;

class LuckController extends Controller
{
    /**
     * 新年活动抽奖
     * @param Request $request
     * @return false|string
     * @throws ValidationException
     * @throws \Throwable
     */
    public function luckLoop(Request $request)
    {
        $params = $this->validate($request,[
            'acId' => 'required|integer'
        ],[],[
            'acId' => '活动ID',
        ]);
        $activityId = $params['acId'];
        $luckRes    = (new LuckServices())->getLuckLoop($activityId);
        if ($luckRes['code'] != 200) {
            return $this->error($luckRes['code']);
        }
        return $this->success($luckRes['data']);
    }

    /**
     * 获取抽奖记录
     * @return false|string
     */
    public function luckLog()
    {
        $luckLogRes = (new LuckServices())->getLuckLog();
        return $this->successForList($luckLogRes);
    }
}